<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.js"></script>

    <title>列表页面</title>
</head>
<body>
商品列表1<br/>
<h1 id="h"></h1>
<table>
    <tr id="t">
        <td>名称</td>
        <td>编号</td>
        <td>价格</td>
        <td>作者</td>
    </tr>
</table>
<script type="text/javascript">
    $(function () {
        $.post("${pageContext.request.contextPath}/book.action", function (data) {
            $("#h").html("欢迎你" + data[1]);
            var html = "";
            for (var i=0;i<data[0].length;i++){
                html+="<tr>" +
                    "   <td>"+data[0][i].bookname+"</td>" +
                    "   <td>"+data[0][i].num+"</td>" +
                    "   <td>"+data[0][i].price+"</td>" +
                    "   <td>"+data[0][i].vender+"</td>" +
                    "  <tr/>";
            }
            $("#t").after(html);
        }, "json");
    });
</script>
</body>
</html>